home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _85A8CC99509B4DD49DD134F7470CF734 < prev    next >
Encoding:
Text File  |  2004-01-06  |  1.3 KB  |  55 lines

  1. -- AI_BoredManager
  2. -- version 1.0 Amanda 2002-10-21
  3. --
  4. -- look for an anchor appropriate to the AI type within specified range, 
  5. -- if find an anchor return identifying string, anchor type and signal otherwise return nil
  6. -- for bored AI this can be used to signal anchor appropriate behavior
  7.  
  8.  
  9. AI_BoredManager = {
  10.  
  11.     -- this table fills automatically when new idles are added in AnimIdles.lua    
  12.     ASTable = {},
  13.  
  14. }
  15.  
  16.  
  17. function AI_BoredManager:FindSomethingToDO(entity,range)
  18.     local NumEntries;
  19.     NumEntries = count(self.ASTable);
  20.     if (NumEntries==0) then
  21.         do return end;
  22.     end
  23.  
  24.     self.SelectedSignal=nil;
  25.     local maxpriority = -1;
  26.     for name,table in self.ASTable do 
  27.         local process = 1;
  28.         if (table.SPECIAL_AI_ONLY and entity.Properties.special) then
  29.             if (entity.Properties.special==0) then
  30.                 process = 0;
  31.             end
  32.         end
  33.  
  34.         if (process==1) then
  35.             local foundObject = AI:FindObjectOfType(entity.id,range,table.anchorType);
  36.             if (foundObject) then
  37.                 if (table.priority > maxpriority) then
  38.                     maxpriority = table.priority;
  39.                     self.SelectedSignal = table;
  40.                       --self.SelectedSignal.tag = 1;
  41.                     return self.SelectedSignal;
  42.                 end
  43.             end
  44.         end
  45.         
  46.     end
  47.  
  48. --    for name,table in self.ASTable do 
  49. --        table.tag = 0;
  50. --    end
  51.         
  52.     return nil;    
  53. end
  54.  
  55.